//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "GarmanKlassSimpleSigma.h"
using namespace Cephei::QL::Models::Volatility;
#include <gen/QL/Models/Volatility/GarmanKlassAbstract.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (Double y) : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
    try
    {
#ifdef HANDLE
        _phGarmanKlassSimpleSigma = NULL;
#endif
        QuantLib::Real _y = (QuantLib::Real)ValueHelper::Convert (y);
        _ppGarmanKlassSimpleSigma = new boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma> (new QuantLib::GarmanKlassSimpleSigma ( _y ));
        SetGarmanKlassAbstract (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma>& childNative, Object^ owner) : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
#ifdef HANDLE
	_phGarmanKlassSimpleSigma = NULL;
#endif
	_ppGarmanKlassSimpleSigma = &childNative;
    _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
}
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (QuantLib::GarmanKlassSimpleSigma& childNative, Object^ owner) : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
#ifdef HANDLE
	_phGarmanKlassSimpleSigma = NULL;
#endif
	_ppGarmanKlassSimpleSigma = new boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma> (&childNative);
    _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
    _GarmanKlassSimpleSigmaOwner = owner;
    _GarmanKlassAbstractOwner = owner;
}

Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (CGarmanKlassSimpleSigma^ copy) : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
#ifdef HANDLE
	_phGarmanKlassSimpleSigma = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppGarmanKlassSimpleSigma = new boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma> (copy->GetShared());
        _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
    }
}
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (System::Type^ t) : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
#ifdef HANDLE
	_phGarmanKlassSimpleSigma = NULL;
#endif
	if (!t->IsSubclassOf(CGarmanKlassSimpleSigma::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (QuantLib::Handle<QuantLib::GarmanKlassSimpleSigma>& childNative, Object^ owner)  : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
	_phGarmanKlassSimpleSigma = &childNative;
	_ppGarmanKlassSimpleSigma = &static_cast<boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma>>(childNative.currentLink());
    _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
    _GarmanKlassSimpleSigmaOwner = owner;
}
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (QuantLib::Handle<QuantLib::GarmanKlassSimpleSigma> childNative)  : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
	_phGarmanKlassSimpleSigma = &childNative;
	_ppGarmanKlassSimpleSigma = &static_cast<boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma>>(childNative.currentLink());
    _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
}
#endif
#ifdef STRUCT
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::CGarmanKlassSimpleSigma (QuantLib::GarmanKlassSimpleSigma childNative)  : CGarmanKlassAbstract(CGarmanKlassSimpleSigma::typeid)
{
#ifdef HANDLE
	_phGarmanKlassSimpleSigma = NULL;
#endif
	_ppGarmanKlassSimpleSigma = new boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma> (new QuantLib::GarmanKlassSimpleSigma (childNative));
    _ppGarmanKlassAbstract = new boost::shared_ptr<QuantLib::GarmanKlassAbstract> (boost::dynamic_pointer_cast<QuantLib::GarmanKlassAbstract> (*_ppGarmanKlassSimpleSigma));
}
#endif

Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::~CGarmanKlassSimpleSigma ()
{
    if (_ppGarmanKlassSimpleSigma != NULL)
    {
	    delete _ppGarmanKlassSimpleSigma;
        _ppGarmanKlassSimpleSigma = NULL;
    }
}
Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::!CGarmanKlassSimpleSigma ()
{
    if (_ppGarmanKlassSimpleSigma != NULL)
    {
	    delete _ppGarmanKlassSimpleSigma;
    }
}
QuantLib::GarmanKlassSimpleSigma& Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::GetReference ()
{
    if (_ppGarmanKlassSimpleSigma == NULL) throw gcnew NativeNullException ();
	return **_ppGarmanKlassSimpleSigma;
}
boost::shared_ptr<QuantLib::GarmanKlassSimpleSigma>& Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::GetShared ()
{
    if (_ppGarmanKlassSimpleSigma == NULL) throw gcnew NativeNullException ();
	return *_ppGarmanKlassSimpleSigma;
}
QuantLib::GarmanKlassSimpleSigma* Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::GetPointer ()
{
    if (_ppGarmanKlassSimpleSigma == NULL) throw gcnew NativeNullException ();
	return &**_ppGarmanKlassSimpleSigma;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::GarmanKlassSimpleSigma>& Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::GetHandle ()
{
	if (_phGarmanKlassSimpleSigma == NULL)
	{
		_phGarmanKlassSimpleSigma = new Handle<QuantLib::GarmanKlassSimpleSigma> (*_ppGarmanKlassSimpleSigma);
	}
	return *_phGarmanKlassSimpleSigma;
}
#endif
bool Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma::HasNative () 
{
	return (_ppGarmanKlassSimpleSigma != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Models::Volatility::IGarmanKlassSimpleSigma^ Cephei::QL::Models::Volatility::CGarmanKlassSimpleSigma_Factory::Create (Double y)
{
    return gcnew CGarmanKlassSimpleSigma ( y);
}
